import thin_render from "./thin_render.mjs";

export function fontawesome_template({ container, template }) {
  let classname = "fa-solid";
  let iconname = template.fa;
  switch (template.fa) {
    case "+":
      iconname = "fa-plus";
      break;
    case "-":
      iconname = "fa-minus";
      break;
    case "edit":
      iconname = "fa-edit";
      break;
    case "del":
    case "delete":
      iconname = "fa-trash";
      break;
    case "search":
      iconname = "fa-search";
      break;
    case "save":
      iconname = "fa-save";
      break;
    case "cancel":
      iconname = "fa-times";
      break;
    case "close":
      iconname = "fa-times";
      break;
    case "refresh":
      iconname = "fa-refresh";
      break;
    default:
      iconname = `fa-${template.fa}`;
  }

  thin_render(container, {
    i: "",
    class: `${classname} ${iconname}`,
    click: template.click,
    event: template.event,
  });
}
